import request from '@/config/axios'
import type { ListType, ListDictType } from './type'

export const getDataList = (params: any): Promise<LoginResponse<ListType>> => {
  return request.get({ url: `/sys/dict/list`, params })
}
// 子级列表
export const getDataDictList = (params: any): Promise<LoginResponse<ListDictType>> => {
  return request.get({ url: `/sys/dictItem/list`, params })
}
//新增接口
export const dictAdd = (data: any): Promise<LoginResponse> => {
  return request.post({ url: `/sys/dict/add`, data })
}
// 删除 horizon-system/sys/dict/deletePhysic/{id}
export const dictDelete = (params: any): Promise<LoginResponse> => {
  return request.delete({ url: `/sys/dict/deletePhysic/${params}` })
}
// 编辑
export const dictEdit = (data: any): Promise<LoginResponse> => {
  return request.post({ url: `/sys/dict/edit`, data })
}
//导出 /horizon-system/sys/dict/exportXls
// export const dictExportXls = (): Promise<exportResponse> => {
//   const headers = {
//     'Content-Type': 'application/x-www-form-urlencoded'
//   }
//   return request.post({
//     url: `/sys/dict/exportXls`,
//     responseType: 'blob',
//     headers: headers
//   })
// }

//刷新缓存 /horizon-system/sys/dict/refleshCache
export const getRefleshCache = (): Promise<LoginResponse> => {
  return request.get({ url: '/sys/dict/refleshCache' })
}

// 字典重复校验接口 /horizon-system/sys/dictItem/dictItemCheck
export const getDictItemCheck = (params: any): Promise<LoginResponse> => {
  return request.get({ url: `/sys/dictItem/dictItemCheck`, params })
}
//子级添加 /horizon-system/sys/dictItem/add
export const dictItemAdd = (data: any): Promise<LoginResponse> => {
  return request.post({ url: `/sys/dictItem/add`, data })
}
//子级编辑 /horizon-system/sys/dictItem/edit
export const dictItemEdit = (data: any): Promise<LoginResponse> => {
  return request.post({ url: `/sys/dictItem/edit`, data })
}

//子级删除 /horizon-system/sys/dictItem/delete
export const dictItemDelete = (params: any): Promise<LoginResponse> => {
  return request.delete({ url: `/sys/dictItem/delete`, params })
}
